home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2000 July / macformat-092.iso / Dreamweaver 3 / Configuration / Inspectors / description.js < prev    next >
Encoding:
Text File  |  1999-12-01  |  2.1 KB  |  63 lines

  1.  
  2.  
  3. //form field names:
  4. //Description - text field
  5.  
  6. // *********** GLOBAL VARS *****************************
  7.  
  8. var helpDoc = MM.HELP_inspDescription;
  9.  
  10. // ******************** API ****************************
  11. function canInspectSelection(){
  12.  
  13.   var metaObj = getSelectedObj();
  14.   return (metaObj.tagName && metaObj.tagName == "META" &&
  15.           metaObj.getTranslatedAttribute("name") && 
  16.           metaObj.getTranslatedAttribute("name").toLowerCase()=="description");
  17. }
  18.  
  19. function inspectSelection(){
  20.   var inspectorState = arguments[0],currKeyVal;
  21.   var contentLayer = findObject("contentField");
  22.   var contentCell = contentLayer.getElementsByTagName("TD").item(0);
  23.   var minText= '<textarea name="Description" onBlur="setMetaTag()" '
  24.   + 'style="width:350;height:32" rows="2" wrap="virtual"></textarea>'
  25.   var maxText='<textarea name="Description" onBlur="setMetaTag()" '+
  26.   'style="width:350;height:76" rows="4" wrap="virtual"></textarea>';
  27.   //change inspector state if needed
  28.   //the rows=X check determines whether current state is min or max
  29.   if (inspectorState=="min"&& (findString('rows="4"',contentCell.innerHTML)||contentCell.innerHTML=="")){
  30.     currKeyVal = findObject("Description").value;
  31.     contentCell.innerHTML=minText;
  32.     findObject("Description").value = currKeyVal;
  33.   }    
  34.   else if (inspectorState=="max" && (findString('rows="2"',contentCell.innerHTML)||contentCell.innerHTML=="")){
  35.     currKeyVal = findObject("Description").value; 
  36.     contentCell.innerHTML=maxText; 
  37.     findObject("Description").value = currKeyVal;
  38.   }
  39.   if (getSelectedObj().getAttribute("content"))     
  40.     findObject("Description").value= getSelectedObj().getAttribute("content");
  41.   else
  42.     findObject("Description").value="";    
  43.  
  44.   showHideTranslated();
  45.   //showHideTranslated( getSelectedObj(), 'tButtonSpan' );
  46. }
  47.  
  48. function findString(stringToFind,stringToLookIn){
  49.   if (stringToLookIn.indexOf(stringToFind)==-1)
  50.     return false;
  51.   return true;    
  52. }
  53.  
  54.  
  55. // ******************** LOCAL FUNCTIONS ****************************
  56.  
  57. function setMetaTag(){
  58.   getSelectedObj().setAttribute("content",findObject("Description").value);
  59. }
  60.  
  61.  
  62.  
  63.